<html>
<head><meta charset="utf-8"><title>try-vs-catch [split from try_trait_v2] · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html">try-vs-catch [split from try_trait_v2]</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227325844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227325844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227325844">(Feb 22 2021 at 19:44)</a>:</h4>
<p>(while we're adjacent to the topic, should <code>try {}</code> blocks actually be called <code>catch {}</code>?) <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="227326769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227326769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227326769">(Feb 22 2021 at 19:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227325844">said</a>:</p>
<blockquote>
<p>(while we're adjacent to the topic, should <code>try {}</code> blocks actually be called <code>catch {}</code>?) <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>
</blockquote>
<p>Maybe we should call it <code>wait {  }</code> or <code>stop {  }</code> to wait/stop the propagation <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="227327095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227327095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227327095">(Feb 22 2021 at 19:53)</a>:</h4>
<p>ah yes, if we use <code>wait</code> to stop the propagation then how about <code>sync</code> to initiate it? sync/wait will be the headline feature of Rust 2021 :P</p>



<a name="227327114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227327114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227327114">(Feb 22 2021 at 19:53)</a>:</h4>
<p>Joke apart, I think <code>catch {  }</code> express the meaning better than <code>try {  }</code>, although I personally don't like its background</p>



<a name="227331438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227331438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227331438">(Feb 22 2021 at 20:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="256342">bstrie</span> <a href="#narrow/stream/213817-t-lang/topic/try_trait_v2.3A.202nd.20attempt/near/227325844">said</a>:</p>
<blockquote>
<p>(while we're adjacent to the topic, should <code>try {}</code> blocks actually be called <code>catch {}</code>?) <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>
</blockquote>
<p>No, because in <code>try{}catch{}</code> the <code>try</code> is the block in which one does the fallible operation, not the one in which one is handling the error.  Note that <code>catch</code> is already reserved after <code>try{}</code> in case such a syntax were to make sense for Rust in the future: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=9e5713786a10651df5d77c9597e1252d">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=9e5713786a10651df5d77c9597e1252d</a></p>
<p>A previous conversation on naming for the block, specifically niko's post that convinced me to go for <code>try</code>: <a href="https://internals.rust-lang.org/t/bikeshed-rename-catch-blocks-to-fallible-blocks/7121/4?u=scottmcm">https://internals.rust-lang.org/t/bikeshed-rename-catch-blocks-to-fallible-blocks/7121/4?u=scottmcm</a></p>



<a name="227331582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227331582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227331582">(Feb 22 2021 at 20:24)</a>:</h4>
<p>See also the RFC that resolved the unresolved question from the original RFC, picking <code>try</code>: <a href="https://rust-lang.github.io/rfcs/2388-try-expr.html">https://rust-lang.github.io/rfcs/2388-try-expr.html</a></p>



<a name="227434093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227434093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eduardo Canellas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227434093">(Feb 23 2021 at 14:03)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> the meaning of <code>try { }</code> should really be tied to "fallible operations"? Combined with the Try trait, it could be used to other types of operations. Imagine a sequence of computations which is desirable to early return in the first success case:</p>
<div class="codehilite"><pre><span></span><code>let x = try {
    technique_a()?;
    technique_b()?;
   technique_c()?;
   &quot;All techniques failed&quot;
}
</code></pre></div>
<p>Currently, to do such a thing (propagate success) I think we would have to <code>if/match</code> or make something weird with <code>Result</code>, (<code>Ok(error), Err(value)</code>)</p>



<a name="227475256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227475256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227475256">(Feb 23 2021 at 18:02)</a>:</h4>
<p>I don't think I follow your argument in that last one.  I definitely agree <code>Try</code> and such shouldn't talk in terms of errors.</p>



<a name="227475653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227475653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227475653">(Feb 23 2021 at 18:04)</a>:</h4>
<p>the very word "try" implies something that might not succeed</p>



<a name="227475772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227475772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227475772">(Feb 23 2021 at 18:05)</a>:</h4>
<p>we could really annoy Haskellers and call it <code>Maybe</code></p>



<a name="227485433"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/try-vs-catch%20%5Bsplit%20from%20try_trait_v2%5D/near/227485433" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/try-vs-catch.20.5Bsplit.20from.20try_trait_v2.5D.html#227485433">(Feb 23 2021 at 19:03)</a>:</h4>
<p>I stand by my <a href="https://internals.rust-lang.org/t/bikeshed-rename-catch-blocks-to-fallible-blocks/7121/4?u=scottmcm">prior comment</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>